package cn.mineserv.video.videoordersystem.utils;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Date;

/**
 * @author 爱吃蛋白的丶圆周率
 * @company 圆周率有限公司
 */
public class TimeUtil {

    /**
     * 获取距离目标时间还要多少秒
     */
    public static Integer getPastSeconds(Long currentSecond) {

        long seconds = System.currentTimeMillis()-currentSecond;
        return (int) seconds;
    }
    /**
     * 获取距离目标时间还要多少秒
     */
    public static Integer getRemainSeconds() {
        LocalDateTime midnight = LocalDateTime.ofInstant(new Date().toInstant(),
                ZoneId.systemDefault()).plusDays(1).withHour(0).withMinute(0)
                .withSecond(0).withNano(0);
        LocalDateTime currentDateTime = LocalDateTime.ofInstant(new Date().toInstant(),
                ZoneId.systemDefault());
        long seconds = ChronoUnit.SECONDS.between(currentDateTime, midnight);
        return (int) seconds;
    }
}
